import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';
import {render} from "@apps/antd-admin/src/hooks/render/renderUtils";
import {shopCateGoryList} from "./api";

export const columns: BasicColumn[] = [
  {
    title: '商家Logo',
    dataIndex: 'shopImg',
    width: 100,
    customRender: render.renderImage,
  },
  {
    title: '商家名称',
    dataIndex: 'shopName',
    width: 100,
  },
  {
    title: '商家类别',
    dataIndex: 'shopTypeName',
    width: 130,
  }
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'shopName',
    label: '商家名称',
    component: 'Input',
    colProps: { span: 7 },
  },
  {
    field: 'shopType',
    label: '商家分类',
    component: 'ApiCascader',
    colProps: { span: 6 },
    componentProps: ({ formModel }) => {
      return {
        api: shopCateGoryList,
        apiParamKey: 'typeId',
        labelField: 'typeName',
        asyncFetchParamKey:'parentId',
        valueField: 'typeId',
        initFetchParams: {
          parentId: '0',
        },
        isLeaf: (record) => {
          return (record.parentId != '0')
        },
        onChange(values) {
          formModel.shopTypes=values.join(",");
        }
      }
    },
  },
];
